<?php
class Photo_model extends CI_Model {
    public function __constrcut() {
        parent::__construct();
        $this->load->database();
    }
    
    public function insert($photo) {
        $this->db->insert('photo', $photo);
        $res = $this->db->affected_rows();
        if ($res > 0) {
            return $this->db->insert_id();
        } else {
            return -1;
        }
    }
    
    public function get($photo_id) {
        $this->db->where('photo_id', $photo_id);
        $query = $this->db->get('photo');
        if ($query->num_rows() > 0) {
            return $query->row_array();
        } else {
            return NULL;
        }
    }
    
    public function get_in($photos) {
        $this->db->where_in('photo_id', $photos);
        $query = $this->db->get('photo');
        if ($query->num_rows() > 0) {
            return $query->result_array();
        } else {
            return NULL;
        }        
    }
}
?>